﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Security.Cryptography;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.RegularExpressions;
using CoreShop.App;
using CoreShop.Library;
using CoreShop.Services;
using System.Windows.Forms;
using CoreShop.Model;
using CoreShop.PrintService;
using SqlSugar;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
using Yitter.IdGenerator;
using SqlSugar.Extensions;
using NPOI.SS.Formula.Functions;
using NPOI.Util;
using System.Drawing;
using Sunny.UI;

namespace CoreShop
{
    /*
     List<Dictionary<string, object>> keyValues = new List<Dictionary<string, object>>();

        keyValues.Insert(0, new Dictionary<string, object>());
        keyValues[0].Add("默认主题色", Color.FromArgb(241,141,0));
        keyValues[0].Add("图片", gs_winpos_group.Properties.Resources.主页_默认);
        keyValues.Insert(0, new Dictionary<string, object>());
        keyValues[0].Add("绿色", Color.FromArgb(121,191,60));
        keyValues[0].Add("图片", gs_winpos_group.Properties.Resources.主页_绿色);
        keyValues.Insert(0, new Dictionary<string, object>());
        keyValues[0].Add("粉色", Color.FromArgb(236, 98, 161));
        keyValues[0].Add("图片", gs_winpos_group.Properties.Resources.主页_粉色);
        keyValues.Insert(0, new Dictionary<string, object>());
        keyValues[0].Add("深黑色", Color.FromArgb(51, 51, 51));
        keyValues[0].Add("图片", gs_winpos_group.Properties.Resources.主页_深黑色);
        keyValues.Insert(0, new Dictionary<string, object>());
        keyValues[0].Add("深蓝色", Color.FromArgb(0, 86, 137));
        keyValues[0].Add("图片", gs_winpos_group.Properties.Resources.主页_蓝灰色);
        keyValues.Insert(0, new Dictionary<string, object>());
        keyValues[0].Add("红色", Color.FromArgb(244, 94, 99));
        keyValues[0].Add("图片", gs_winpos_group.Properties.Resources.主页_红色);
     
     */


    public class SkinUtil
    {
        /// <summary>
        /// 皮肤颜色
        /// Panel的背景颜色
        /// </summary>
        public static string skinTagString = "SkinCustom";

        /// <summary>
        /// 皮肤颜色
        /// Panel的背景颜色
        /// </summary>
        public static Color panelBackColor { get; set; } = Color.FromArgb(0, 86, 137);

        /// <summary>
        /// 皮肤颜色
        /// Panel的背景颜色
        /// </summary>
        public static Color panelFillColor { get; set; } = Color.FromArgb(0, 86, 137);

        /// <summary>
        /// 皮肤颜色
        /// Panel的边框
        /// </summary>
        public static Color panelRectColor { get; set; } = Color.FromArgb(0, 86, 137);

        /// <summary>
        /// 按钮颜色
        /// </summary>
        public static Color buttonBackColor { get; set; } = Color.FromArgb(0, 86, 137);

        /// <summary>
        /// 皮肤颜色
        /// Panel的边框
        /// </summary>
        public static Color buttonRectColor { get; set; } = Color.FromArgb(0, 86, 137);

        public static void TraverseControls(Control control)
        {
            foreach (Control ctr in control.Controls)
            {
                if (ctr is UIPanel)
                {
                    if ((ctr as UIPanel).TagString == skinTagString)
                    {
                        (ctr as UIPanel).BackColor = panelBackColor;
                        (ctr as UIPanel).FillColor = panelFillColor;
                    }
                } 
                else 
                if (ctr is UIButton)
                {
                    if ((ctr as UIButton).TagString == skinTagString)
                    {
                        (ctr as UIButton).BackColor = System.Drawing.Color.Transparent;
                        (ctr as UIButton).FillColor = buttonBackColor;
                        (ctr as UIButton).RectColor = buttonRectColor;
                    }
                }
                // 如果控件有子控件，递归调用
                if (ctr.Controls.Count > 0)
                {
                    TraverseControls(ctr);
                } 
            }
        }

    }
}
